<?php
namespace api\album\controller;

use app\album\model\AlbumUserModel;
use cmf\controller\RestBaseController;
use \think\Request;


class UserController extends RestBaseController
{

    //注册
    function registSubmit()
    {
        $param = $this->request->param();
        $userName = $param['username'];
        $password = $param['password'];

        if(empty($userName)||empty($password)){
            exit('用户名或密码不能为空！');
        }

        $user = new AlbumUserModel;
        $user->data([
            'username' => $userName,
            'password' => $password,
            'regdate' => time(),
            'islock' => 1, //0锁定，1正常
        ]);
        $user->save();

        //获取自增主键userID
        //echo $user->userid;
        echo "注册成功";
    }

    //登录
    function loginSubmit()
    {
        $param = $this->request->param();
        $userName = $param['username'];
        $password = $param['password'];


        $user = new AlbumUserModel();

        //$resUser  = $user->where('userid', 9)->find();
        //$resUser  = $user->where('userid', 9)->find();
        $resUser  = $user::get(['username'=> $userName]);
        var_dump($resUser);
        if($resUser["password"]==$password){

            echo "登录成功";
            echo $resUser;
        }else{
            echo "登录失败";
        }





    }
}